#include <cstdio>
#include <fstream>
#include <iostream>
#include <vector>

#include "left_turn_predicate.h"

using std::vector;
using std::cin;
using std::cout;

double MAXX = -1E50;

bool in_edge(point & a, point & b, point &p)
{
    if ((p.x > a.x && p.x > b.x) || 
        (p.x < a.x && p.x < b.x) || 
        (p.y > a.y && p.y > b.y) || 
        (p.y < a.y && p.y < b.y))
        return false;
   return left_turn_predicate(a, b, p) == 0;
}

int in_polygon(vector<point>& polygon, point &p, point &p_end)
{
    int is_num = 0;
    for (size_t i = 1; i < polygon.size(); i++)
    {
        if (in_edge(polygon[i - 1], polygon[i], p)) return 0;
        if (intersect(polygon[i - 1], polygon[i], p, p_end)) ++is_num;
    }
    if ((is_num & 1) != 0) return 1;
    return -1;
}

int main()
{
    int n, m, si;
    int answer, in_hole = -1;
    point p, p_e;
    cin >> n;

    vector<point> polygon(n);
    vector< vector<point> > holes;
        
    for (int i = 0; i < n; ++i)
    {
        cin >> polygon[i].x >> polygon[i].y;
        MAXX = std::max(MAXX, polygon[i].x);
    }
    polygon.push_back(polygon[0]);
    cin >> m;
    for (int i = 0; i < m; ++i)
    {                            
        cin >> si;
        vector<point> hole(si);
        for (int j = 0; j < si; ++j)
            cin >> hole[j].x >> hole[j].y;
        hole.push_back(hole[0]);
        holes.push_back(hole);
    }
    int cnt = 0;
    cin >> cnt;
    for (int i = 0; i < cnt; ++i)
    {
        cin >> p.x >> p.y;
        p_e.x = MAXX + 100;
        p_e.y = p.y + 0.1;
        answer = in_polygon(polygon, p, p_e);
        in_hole = -1;
        if (answer == 1)
            for (size_t j = 0; j < holes.size(); ++j)
            {
                in_hole = in_polygon(holes[j], p, p_e);
                if (in_hole != -1) break;
            }
        
        if (answer == 0 || in_hole == 0)
        {
            cout << "0\n";
            continue;
        }
        if (answer == -1 || in_hole == 1)
        {
            cout << "-1\n";
            continue;
        }
        if (answer == 1 && in_hole == -1)
            cout << "1\n";    
    }
}